﻿using System.Windows.Controls;
using System.Windows.Input;

namespace Heyo.Controls
{
    /// <summary>
    /// CrossButton.xaml 的交互逻辑
    /// </summary>
    public partial class CloseButton : UserControl
    {
        public CloseButton()
        {
            InitializeComponent();
        }

        public ICommand Command
        {
            get => (ICommand)GetValue(Button.CommandProperty);
            set
            {
                SetValue(Button.CommandProperty,value);
            }
        }
        public object CommandParameter
        {
            get => (ICommand)GetValue(Button.CommandParameterProperty);
            set
            {
                SetValue(Button.CommandParameterProperty, value);
            }
        }
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);
            if(Command.CanExecute(CommandParameter))
                Command.Execute(CommandParameter);
        }
    }
}
